import Api from 'api';
class WebApi {
    queryOrderList = (params = {}) => Api({
        url: 'afterSale/applyList',
        method: 'POST',
        body: Object.assign({}, params)
    });


    startExportOrder = (params = {}) => Api({
        url: 'order/export/start',
        method: 'POST',
        body: Object.assign({}, params)
    });

    queryExport = (exportId = '') => Api({
        url: `order/export/pull/${exportId}`,
        method: 'GET',
    });


    downloadOrder = (exportId = '') => Api({
        url: `order/export/download/${exportId}`,
        method: 'GET',
    });

    /**
     * 退款时，需要查询实际可退金额，和相应订单信息
     * @param {string } id 服务单编号
     */
    fetchRefundOrderInfo = (id) => {
        return Api({
            url:`afterSale/refund/${id}`,
            method:"POST",
            body:{}
        })
    }

    confirmRefund = (refund) => {
        return Api({
            url:'afterSale/refund',
            method:"POST",
            body:refund
        })
    }

    /**
     * 审核售后订单
     * @param {id } 服务单编号
     * @param {* boolean} checkout
     */
    auditAfterSaleOrder = (id,checkout) => {
        return Api({
            url:`afterSale/audit/${id}/${checkout}`,
            method:"POST",
            body:{}
        })
    }
    /**
     * 取消售后申请，关闭订单
     * @param { id } 服务单编号
     */
    cancelAfterSaleOrder = ( id ) => {
        return Api({
            url:`afterSale/cancel/${id}`,
            method:"POST",
            body:{}
        })
    }

    /**
     * 签收退货
     * @param {string} id 服务单编号
     */
    receivedGoods = (id) => {
        return Api({
            url:`afterSale/receiveGoods/${id}`,
            method:"POST",
            body:{}
        })
    }

}

export default new WebApi();